package com.hdu.joinInMemory.entity.VO;


import com.hdu.joinInMemory.annotation.*;
import com.hdu.joinInMemory.enums.JoinInMemeoryExecutorType;
import lombok.Data;


@Data
@JoinInMemoryConfig(executorType = JoinInMemeoryExecutorType.SERIAL)
public class OrderDetailVO {

    private final OrderVO order;

    @JoinInMemory(keyFromSourceData = "#{order.userId}",
            loader = "#{@userRepository.findUserById(#root)}",
            keyFromJoinData = "#{id}",
            joinDataConverter = "#{T(com.hdu.joinInMemory.entity.VO.UserVO).apply(#root)}"
    )
    private UserVO user;

    @JoinInMemory(keyFromSourceData = "#{order.addressId}",
            loader = "#{@addressRepository.findAddressById(#root)}",
            keyFromJoinData = "#{id}",
            joinDataConverter = "#{T(com.hdu.joinInMemory.entity.VO.AddressVO).apply(#root)}"
    )
    private AddressVO address;

    @JoinInMemory(keyFromSourceData = "#{order.productId}",
            loader = "#{@productRepository.findProductById(#root)}",
            keyFromJoinData = "#{id}",
            joinDataConverter = "#{T(com.hdu.joinInMemory.entity.VO.ProductVO).apply(#root)}"
    )
    private ProductVO product;
}
